/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package controleur;

import modele.Client;
import modele.InterfaceClient;
import org.apache.struts.actions.DispatchAction;
import traitements.ClientForm;

/**
 *
 * @author Jean-Michel
 */
public class GenericAction extends DispatchAction {
    
    private InterfaceClient modele = null;
    
    public void setModele(InterfaceClient s) {
        modele = s;
    }
    
    public InterfaceClient getModele() {
//        ServletContext context = request.getServletContext();
//        return (InterfaceEmploye) context.getAttribute("ModeleEmploye");
        return modele;
        
    }

    //bean -> form 
    protected Client beanEmploye(ClientForm eForm) {
//           EmployeForm eForm = (EmployeForm) form;
        
        Client employeUpdate = new Client();
        employeUpdate.setNom(eForm.getNom());
        employeUpdate.setAdresse(eForm.getAdresse());
        employeUpdate.setDateCrea(eForm.getDateCrea());
        employeUpdate.setDateNaiss(eForm.getDateNaiss());
//           employeUpdate.setId(eForm.get());
        employeUpdate.setNbCompte(eForm.getNbCompte());
        employeUpdate.setPrenom(eForm.getPrenom());


//           System.out.println(employeUpdate.getEmail().toString());
        
        return employeUpdate;
    }
    
    protected ClientForm beanForm(Client clt) {
        ClientForm form = new ClientForm();
        
        form.setAdresse(clt.getAdresse());
        form.setDateCrea(clt.getDateCrea());
        form.setDateNaiss(clt.getDateNaiss());
        form.setNbCompte(clt.getNbCompte());
        form.setNom(clt.getNom());
        form.setPrenom(clt.getPrenom());
        return form;
    }
    //form-> bean

}
